import { defineStore } from 'pinia'
import type { UserType, UserInfoType } from './types'

export const useUserStore = defineStore('user', {
  // 开启持久化
  persist: {
    key: 'userStore',
    storage: localStorage
  },
  state: (): UserType => ({
    userInfo: {}
  }),
  getters: {
    // userName: (state) => state.userName
  },
  actions: {
    setUserInfo(data: UserInfoType) {
      this.userInfo = data
    }
  }
})
